package com.xyw.code.study202007291.trywithcatch;

/**
 * Created with IntelliJ IDEA.
 * User: xuyiwei
 * Date: 2020/7/30
 * Time: 下午1:46
 * Email: 1328312923@qq.com
 * Description: No Description
 **/
public class ResourceIn1 implements AutoCloseable{
    void doSome() throws Exception {
        //System.out.println("do something");
        throw new Exception("抛出异常");
    }
    @Override
    public void close() throws Exception {
       // System.out.println("resource is closed");
        throw new Exception("关闭资源");
    }

    public static void main(String[] args) {
        try(ResourceIn1 resourceIn1 = new ResourceIn1();ResourceIn1 resourceIn2 = new ResourceIn1()){
            resourceIn1.doSome();
            resourceIn2.doSome();
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
